package string;

import java.util.Arrays;

public class SplitDemo {
    public static void main(String[] args) {

        String str = "hello world";
        String[] strArray = str.split(" ");
        for (String s : strArray) {
            System.out.println(s);
        }
        System.out.println("~~~~~~~~~~~~~~~~~~");
        String str1 = "hello world.123java.python.c++12312312312";
        String[] strArray1 = str1.split("\\d+");
        for (String string : strArray1) {
            System.out.println(string);
        }
        System.out.println(Arrays.toString(strArray1));

        String line = "==213==12333==55324423==";
        String[] strArray2 = line.split("=");
        System.out.println(Arrays.toString(strArray2));
        System.out.println(strArray2.length);

        String string = "12341324 == 234!= _$#%@!@^&*()_+";
        String[] strArray3 = string.split("\\w+");
        System.out.println(Arrays.toString(strArray3));
        System.out.println(strArray3.length);
        String[] strArray4 = string.split("\\s+");
        System.out.println(Arrays.toString(strArray4));
        System.out.println(strArray4.length);
    }
}
